<template>
	<view class="content" v-show="load">
		<view class="status">
			<view>{{detail.statusMsg}}</view>
		</view>
		<view class="refund-amount">
			<view class="refund-amount-label">退款金额</view>
			<view class="refund-amount-num">￥{{detail.amount}}</view>
		</view>

		<view class="record">
			<view v-for="(item,index) in detail.records" :key="index">
				<view class="time-line">
					<view :class="[index==0?'time-line-empty':'time-line-gray']"></view>
					<view :class="[index==0?'time-line-dto-red':'time-line-dto-gray']"></view>
					<view :class="[index+1==detail.records.length?'time-line-empty':'time-line-gray']"></view>
				</view>
				<view class="time-line-content">
					<view class="time-line-text">{{item.message}}
						<view class="operation" v-if="index==0&&detail.status==2" @tap="continueOrder">继续订单</view>
						<view class="operation" v-if="index==0&&detail.status==2" @tap="continueRefund">再次申请</view>
					</view>
					<view v-if="item.reason!=null&&item.reason!=''" class="time-line-time">({{item.reason}})</view>
					<view class="time-line-reason">{{item.time}}</view>
				</view>
			</view>
		</view>

		<view class="refund-message">
			<view class="label">退款信息</view>
			<view v-for="(item,index) in detail.products" :key="index" class="item">
				<image :src="item.image" class="product-image"></image>
				<view class="product-right">
					<view class="product-name text_two">{{item.productName}}</view>
					<view class="product-sku-name text_one">{{item.skuName}}</view>
				</view>
			</view>
			<view class="label-item">
				<view class="label-name">退款编号</view>
				<view class="lable-value">{{detail.refundNo}}</view>
			</view>
			<view class="label-item">
				<view class="label-name">退款原因</view>
				<view class="lable-value">{{detail.reason}}</view>
			</view>
			<view class="label-item">
				<view class="label-name">退款金额</view>
				<view class="lable-value">{{detail.amount}}</view>
			</view>
			<view class="label-item">
				<view class="label-name">申请时间</view>
				<view class="lable-value">{{detail.time}}</view>
			</view>
		</view>
		<view class="contact">
			<image src="../../static/icon/kfff.png" class="kf-icon"></image>
			<view class="contact-font">联系我们</view>
			<button open-type="contact" class="open_bt"></button>
		</view>
	</view>
</template>

<script>
	import api from "../../common/api.js"
	import {
		getWithParam_
	} from "../../common/request.js";
	export default {
		data() {
			return {
				load: false,
				orderId: 0,
				detail: {}
			}
		},
		onLoad(option) {
			this.orderId = option.id
			this.initData()
		},
		methods: {
			continueOrder() {
				var that = this
				uni.showModal({
					title: '',
					content: '继续订单,将无法再次进行退款操作',
					success: function(res) {
						if (res.confirm) {
							getWithParam_(api.ORDER_CONTINUE, {
								orderId: that.orderId
							}).then(res => {
								uni.navigateTo({
									url: "./detail?id=" + that.orderId
								})
							})
						}
					}
				});
			},
			continueRefund() {
				var that = this
				uni.showModal({
					title: '',
					content: '是否再次发起退款申请',
					success: function(res) {
						if (res.confirm) {
							getWithParam_(api.ORDER_CONTINUE_REFUND, {
								orderId: that.orderId
							}).then(resp => {
								that.load = false
								that.initData()
							})
						}
					}
				});
			},
			initData() {
				getWithParam_(api.ORDER_REFUND_DETAIL, {
					orderId: this.orderId
				}).then(res => {
					this.detail = res.data
					this.load = true
				})
			}
		}
	}
</script>

<style>
	.operation {
		color: #555555;
		font-size: 24upx;
		background-color: rgba(0, 0, 0, 0.3);
		margin-left: 15upx;
		border-radius: 30upx;
		padding: 5upx 20upx;
	}

	.status-button {
		padding: 10upx 20upx;
		border-radius: 50upx;
		border: 3upx solid #FFFFFF;
		margin: 10upx;
	}

	.time-line-time {
		margin-top: 10upx;
		color: #888888;
		font-size: 24upx;
	}

	.time-line-reason {
		margin-top: 5upx;
		color: #888888;
		font-size: 24upx;
	}

	.time-line-text {
		color: #333333;
		align-items: center;
	}

	.time-line-content {
		flex-direction: column;
		margin: 20upx;
	}

	.time-line-dto-red {
		width: 12upx;
		height: 12upx;
		border-radius: 12upx;
		background-color: #FE0036;
	}

	.time-line-dto-gray {
		width: 12upx;
		height: 12upx;
		border-radius: 12upx;
		background-color: #999999;
	}

	.time-line-gray {
		flex: 1;
		background-color: #999999;
		width: 3upx;
	}

	.time-line-empty {
		flex: 1;
		background-color: #FFFFFF;
		width: 3upx;
	}

	.time-line {
		width: 100upx;
		justify-content: center;
		align-items: center;
		flex-direction: column;
	}

	.record {
		background-color: #FFFFFF;
		padding: 20upx 30upx;
		box-sizing: border-box;
		flex-direction: column;
	}

	.refund-amount-num {
		color: #FE0036;
		font-size: 32upx;
	}

	.refund-amount-label {
		color: #333333;
		font-size: 32upx;
	}

	.refund-amount {
		margin-top: 20upx;
		height: 100upx;
		align-items: center;
		justify-content: space-between;
		padding: 0 30upx;
		background-color: #FFFFFF;
	}

	.status {
		height: 120upx;
		background-color: #F95706;
		font-size: 32upx;
		color: #FFFFFF;
		align-items: center;
		justify-content: center;
	}

	.contact-font {
		font-size: 32upx;
		color: #333333;
		margin-left: 15upx;
	}

	.kf-icon {
		height: 40upx;
		width: 40upx;
	}

	.contact {
		margin-top: 30upx;
		position: relative;
		height: 100upx;
		align-items: center;
		justify-content: center;
		background-color: #FFFFFF;

	}

	.lable-value {
		color: #888888;
		margin-left: 20upx;
	}

	.label-name {
		color: #555555;
	}

	.label-item {
		padding: 10upx 30upx;
		box-sizing: border-box;
	}

	.product-sku-name {
		margin-top: 15upx;
		color: #888888;
		font-size: 24upx;
	}

	.product-name {
		margin-top: 10upx;
		color: #555555;
	}

	.product-right {
		width: ;
		margin-left: 20upx;
		flex: 1;
		flex-direction: column;
	}

	.product-image {
		width: 150upx;
		height: 150upx;
	}

	.item {
		width: 100%;
		background-color: #F2F3F5;
		padding: 30upx;
		box-sizing: border-box;
	}

	.refund-message .label {
		padding: 20upx 30upx;
		font-size: 32upx;
		color: #555555;
		font-weight: 800;
	}

	.refund-message {
		background-color: #FFFFFF;
		flex-direction: column;
		box-sizing: border-box;
		width: 100%;
		margin-top: 20upx;
	}
</style>
